//
//  MeViewController.swift
//  许鲜
//
//  Created by hbl on 16/4/22.
//  Copyright © 2016年 hbl. All rights reserved.
//

import UIKit
import AFNetworking

class MeViewController: UIViewController {
    
    @IBOutlet weak var money: UILabel!
    @IBOutlet weak var coupon: UILabel!
    @IBOutlet weak var point: UILabel!
    
    var meInfo:[String:String]?
    override func viewDidLoad() {
        super.viewDidLoad()
        
        // Do any additional setup after loading the view.
        getData()
    }
    
    func getData(){
        let meneger = AFHTTPSessionManager()
        meneger.responseSerializer = AFHTTPResponseSerializer()
        var params = Dictionary<String,String>()
        params["userid"] = "1392684"
        params["token"] = "43971688ee325a14527ef4286399c444"
        
        meneger.POST("http://mobile.xuxian.com/user/getuserinfo/?ver=2016040101", parameters: params, progress: nil, success: { (_, JSON) in
            do{
                let str = try NSJSONSerialization.JSONObjectWithData(JSON as! NSData , options: NSJSONReadingOptions.MutableContainers)["data"] as! Dictionary<String, AnyObject>
                NSOperationQueue.mainQueue().addOperationWithBlock({ 
                    self.money.text = str["balance"] as! String + "元"
                    self.coupon.text = String(str["payment"]!)
                    self.point.text = str["point"] as! String + "个"
                })
            }catch{}
            }) { (_, error) in
                print(error)
        }
    }
    
    
}
